package cn.lastcrdg.testresultreceiver;

import android.os.Bundle;
import android.os.ResultReceiver;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * author：liluo
 * e-mail：lastcrazysun@163.com
 * company：cusc
 * date：2017/11/28 14:56
 * description：
 */

public class SecondActivity extends AppCompatActivity {

    private ResultReceiver mResult;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        Button button = findViewById(R.id.button2);
        mResult = getIntent().getParcelableExtra("result");
        final TextView textView = findViewById(R.id.textView2);
        String result_msg = getIntent().getStringExtra("result_msg");
        textView.setText(result_msg);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("result_second", "我是收到之后回传的消息");
                mResult.send(MainActivity.REQUEST_CODE, bundle);
            }
        });
    }
}
